import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:qianyi/controller/webSockerController.dart';
import 'package:qianyi/entity/message/Message.dart';
import 'package:qianyi/entity/message/UserRecord.dart';
import 'package:qianyi/state/token.dart';

import '../../network/http_config.dart';
import '../../network/http_entity.dart';
import '../../network/http_manager.dart';
import '../../ui/widget/custom_refresh_mixin.dart';

class UserRecordViewModel extends ChangeNotifier with CustomRefreshMixin{
  WebSocketController webSocketController = Get.find();
  TextEditingController introduceController = TextEditingController();
  TokenController tokenController = Get.find();
  @override
  Future<List> requestList(int page) async {
    List tempL = [];
    Map<String, dynamic> params = {};

    // String id = UserManager.userEntity!.userInfo!.id!;

    params["uid"] = await tokenController.getUid();;

    HttpEntity? result = await HttpManager.getInstance().request(url: "/platform/user/getUserRecord", params: params,method: Method.get) as HttpEntity;

    UserRecord listResult = UserRecord.fromJson(result.getOriData()["data"]);
    UserRecord temps = listResult; // 这里不需要强制类型转换
    if (temps != null) {
      tempL.add(temps);
    }

    webSocketController.setListenData(result.getOriData()['data']);
    return tempL;
  }


  @override
  void onRequestComplete() {
    notifyListeners();
  }

  void onrefreshXt() {
    this.onRefresh();
    notifyListeners();
  }

}